var t = require;
var e = module;
var o = exports;
var a,
    i =
    (this && this.__extends) ||
    ((a = function(t, e) {
            return (a =
                Object.setPrototypeOf ||
                ({ __proto__: [] }
                    instanceof Array &&
                    function(t, e) {
                        t.__proto__ = e;
                    }) ||
                function(t, e) {
                    for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                })(t, e);
        }),
        function(t, e) {
            a(t, e);

            function o() {
                this.constructor = t;
            }
            t.prototype = null === e ? Object.create(e) : ((o.prototype = e.prototype), new o());
        });
Object.defineProperty(o, "__esModule", { value: !0 });
var n = t("BaseManager"),
    r = t("GameCof"),
    s = (function(t) {
        i(e, t);

        function e(e, o) {
            void 0 === o && (o = !1);
            var a = t.call(this, e, o) || this;
            a.onceData = {};
            if (o) {
                a.loadData();
                a.init();
            }
            return a;
        }
        e.prototype.init = function() {};
        return e;
    })(n.ArchiveBase),
    c = (function() {
        function t() {
            this.keyData = {};
            this.lastTime = {};
            this.canSend = !0;
        }
        t.prototype.checkTime = function(t) {
            var e = this.keyData[t] || 0,
                o = this.lastTime[t] || 0;
            if (Date.now() - o > 5e3) {
                this.lastTime[t] = Date.now();
                this.keyData[t] = 0;
            } else this.keyData[t] = e + 1;
            if (this.keyData[t] > 10 && this.canSend) {
                this.canSend = !1;
                console.log("QReportBase -----------------账户发送异常 ", t);
            }
        };
        return t;
    })(),
    p = (function() {
        function t() {
            this.saveKey = "QReportBaseSave";
            this.timeDataCheck = null;
            this.sendKind = 0;
            this.isLoad = !1;
            this.eventIdAry = [];
            this.lastTimeLimite = 0;
            this.timeLimite = 500;
            this.initAccount("");
        }
        t.prototype.initAccount = function(t) {
            this.saveKey = "QReportBaseSave" + t;
            this._archive = new s(this.saveKey, !0);
            this.timeDataCheck = new c();
        };
        t.prototype.send = function(t, e, o) {
            void 0 === e && (e = 1);
            void 0 === o && (o = "value");
            this.timeDataCheck.checkTime(t);
            console.log("QReport ----------------- 发送" + t, this.timeDataCheck.canSend);
            if (r.default.isMiniGame) {
                if (!r.default.adConfig) return;
                if (r.default.adConfig && 1 != r.default.adConfig.ae) {
                    console.log(r.default.adConfig.ae, "不上报");
                    return;
                }
            }
            this.timeDataCheck.canSend && this.sendData(t, o, e);
        };
        t.prototype.sendOnce = function(t, e, o) {
            void 0 === e && (e = 1);
            void 0 === o && (o = "value");
            if (!this._archive.onceData[t]) {
                this._archive.onceData[t] = !0;
                this._archive.saveData();
                this.sendData(t, o, e);
            }
        };
        t.prototype.sendData = function(t, e, o) {
            if (!this.isLoad) {
                this.getPlatform();
                this.isLoad = !0;
            }
            switch (this.sendKind) {
                case 0:
                    this.uma(t, e, o);
            }
        };
        t.prototype.uma = function(t, e, o) {
            // this.getPlatform(), ({}[e] = o);
            // cc.sys.platform == cc.sys.ANDROID &&
            //     setTimeout(function() {
            //         jsb.reflection.callStaticMethod(
            //             "org/cocos2dx/javascript/AppActivity",
            //             "calculateData",
            //             "(I)V",
            //             parseInt(t)
            //         );
            //     }, 1e3);
            // this.sendSelfSer(t);
        };
        t.prototype.sendSelfSer = function(t, e) {
            var o = this;
            void 0 === e && (e = !0);
            e && this.eventIdAry.push(parseInt(t));
            "" != r.default.UID ?
                this.trySend() :
                setTimeout(function() {
                    o.sendSelfSer("", !1);
                }, 1e3);
        };
        t.prototype.trySend = function() {
            // var t = this;
            // if ("" != r.default.UID) {
            //     if (Date.now() - this.lastTimeLimite < this.timeLimite) {
            //         setTimeout(function () {
            //             t.trySend();
            //         }, this.timeLimite);
            //         return;
            //     }
            //     if (this.eventIdAry.length > 0) {
            //         this.lastTimeLimite = Date.now();
            //         var e = r.default.platname,
            //             o = {
            //                 uid: null != r.default.UID ? r.default.UID : 0,
            //                 eventIdAry: JSON.stringify(this.eventIdAry),
            //                 platform: e,
            //                 gameid: r.default.gameid,
            //                 channel: r.default.channel
            //             },
            //             a = "https://xmtx.yonyow.com/api.user.v2/" + r.default.reportEventPath;
            //         a = encodeURI(a);
            //         this.eventIdAry.length = 0;
            //         GameBaseManager.requestJson(a, function () {}, this, "POST", null, o, "application/json");
            //     }
            // }
        };
        t.prototype.pointLog = function() {};
        t.prototype.getPlatform = function() {
            return window.wx;
        };
        return t;
    })();
o.default = p;